package game;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glColor3f;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glVertex2i;
import interfaces.IDrawable;

public class LivesIndicator implements IDrawable
{
	public LivesIndicator()
	{
		this.lives = 100;
	}
	
	public void redraw()
	{
		if (lives >= 90)
		{
			glColor3f(0.0f, 1.0f, 0.0f);
		}
		else
		if (lives >= 70)
		{
			glColor3f(0.0f, 0.8f, 0.0f);
		}
		else
		if (lives >= 50)
		{
			glColor3f(1.0f, 0.0f, 0.0f);
		}
		else
		if (lives >= 20)
		{
			glColor3f(0.6f, 0.0f, 0.0f);
		}
		else
		{
			glColor3f(0.5f, 0.0f, 0.0f);
		}
		
		glLineWidth(1.0f);
		glBegin(GL_LINE_LOOP);
			glVertex2i(x, y);
			glVertex2i(x + WIDTH, y);
			glVertex2i(x + WIDTH, y + HEIGHT);
			glVertex2i(x, y + HEIGHT);
		glEnd();
		glBegin(GL_QUADS);
			glVertex2i(x + WIDTH - lives, y);
			glVertex2i(x + WIDTH, y);
			glVertex2i(x + WIDTH, y + HEIGHT);
			glVertex2i(x + WIDTH - lives, y + HEIGHT);
		glEnd();
	}
	
	public void setLives(int lives)
	{
		this.lives = lives;
	}
	
	private int lives;
	
	private int x				= 910;
	private int y				= 10;
	
	private final int WIDTH		= 100;
	private final int HEIGHT	= 5;
}
